package com.jty.lib_base.binding.viewapapter.text

import android.graphics.Color
import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.BindingAdapter
import androidx.databinding.ObservableInt
import com.jty.lib_base.data.bean.CodeNameItem
import com.jty.lib_base.data.bean.IdNameItem
import com.jty.lib_base.data.bean.UserInfoBean
import com.jty.lib_base.extension.loadUrl
import com.orhanobut.logger.Logger


/**
 * author: zhouyh
 * created on: 2021/9/21 1:22 下午
 * description:imageView的注入函数类
 */
object ViewAdapter {
    @JvmStatic
    @BindingAdapter(value = ["textList"], requireAll = false)
    fun setTextList(textView: TextView, list: List<IdNameItem>?) {
        var str : String = ""
        if (list.isNullOrEmpty()) {

        } else {
            for ((index, value) in list.withIndex()) {
                str += if(index == 0) value.name else "、" + value.name
            }
        }
        textView.setText(str)
    }

//    @JvmStatic
//    @BindingAdapter(value = ["textListSubject"], requireAll = false)
//    fun setTextListSubject(textView: TextView, list: List<UserInfoBean.SubjectBean>?) {
//        var str : String = ""
//        if (list.isNullOrEmpty()) {
//
//        } else {
//            for ((index, value) in list.withIndex()) {
//                str += if(index == 0) value.schoolPhaseName + value.subjectName else "、" + value.schoolPhaseName + value.subjectName
//            }
//        }
//        textView.setText(str)
//    }

    @JvmStatic
    @BindingAdapter(value = ["background"], requireAll = false)
    fun setBackgroundColor(textView: TextView, bk: String?) {
        if (bk == null) {
            return
        }
        textView.setBackgroundColor(Color.parseColor(bk))
    }



}